#include "Generate_C_std.h"

/*
 * global $a or global $$a
 */
class Pattern_global : public Pattern 
{
public:
	bool match(Statement* that)
	{
		var_name = new Wildcard<Variable_name>;
		return(that->match(new Global(var_name)));
	}

	void generate_code(Generate_C* gen)
	{
		if (isa<VARIABLE_NAME> (var_name->value))
			INST (buf, "global_var", var_name->value);
		else
			INST (buf, "global_var_var",
				dyc<Variable_variable> (var_name->value)->variable_name);
	}

protected:
	Wildcard<Variable_name>* var_name;
};

CREATE(Pattern_global);
